package org.nimi317.web_gis.form.post;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.nimi317.web_gis.Enum.LstmUpdaterEnum;
import org.nimi317.web_gis.entity.Lstm;

/**
 * @author thunderobot
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LstmPost {

    @NotNull(message = "学习率不能为空")
    @Min(value = 0, message = "学习率不能小于0")
    private Double learningRate;

    @NotNull(message = "隐藏单元数不能为空")
    @Min(value = 0, message = "隐藏单元数不能小于0")
    private Integer hiddenCell;

    @NotNull(message = "l2正则不能为空")
    @Min(value = 0, message = "l2正则不能小于0")
    private Double l2;

    //更新器
    @NotNull(message = "更新器不能为空")
    private LstmUpdaterEnum updater;

    public Lstm toLstm(Integer modelId, Integer index) {
        Lstm lstm = new Lstm();
        lstm.setL2(l2);
        lstm.setLearningRate(learningRate);
        lstm.setModelId(modelId);
        lstm.setUpdater(updater);
        lstm.setIndex(index);
        lstm.setHiddenCell(hiddenCell);
        return lstm;
    }
}
